﻿using System;
using System.Runtime.InteropServices;
using Microsoft.VisualStudio.Project;
using Microsoft.WowAddonStudio.Project;

using IOleServiceProvider = Microsoft.VisualStudio.OLE.Interop.IServiceProvider;

namespace Microsoft.WowAddonStudio.Project
{
	/// <summary>
	/// Project node factory for WoW projects.
	/// </summary>
	[Guid(GuidStrings.WowProjectFactory)]
	public class WowProjectFactory : ProjectFactory
	{
		/// <summary>
		/// Initializes a new instance of the <see cref="WowProjectFactory"/> class.
		/// </summary>
		/// <param name="package">The package this project factory belongs to.</param>
		public WowProjectFactory(WowProjectPackage package)
			: base(package)
		{
		}

		/// <summary>
		/// Creates a WoW project node.
		/// </summary>
		/// <returns>An instance of the <see cref="WowProjectNode"/> class.</returns>
		protected override ProjectNode CreateProject()
		{
			// Create the project node instance
			var projectNode = new WowProjectNode(Package as WowProjectPackage);

			// Site the project node using the package's service provider
			projectNode.SetSite((IOleServiceProvider) ((IServiceProvider) Package).GetService(typeof (IOleServiceProvider)));

			// Return the project node
			return projectNode;
		}
	}
}